package com.dulichdanang.rssreader;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.dulichdanang.R;
import com.dulichdanang.rssreader.image.ImageLoader;
import com.dulichdanang.rssreader.parser.RSSFeed;

public class DetailActivity extends Activity {

	RSSFeed feed;
	TextView title;
	WebView desc;
	TextView link;
	public ImageLoader imageLoader;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.rssreader_detail);

		// Enable the vertical fading edge (by default it is disabled)
		ScrollView sv = (ScrollView) findViewById(R.id.sv);
		sv.setVerticalFadingEdgeEnabled(true);

		// Get the feed object and the position from the Intent
		feed = (RSSFeed) getIntent().getExtras().get("feed");
		int pos = getIntent().getExtras().getInt("pos");

		// Initialize the views
		title = (TextView) findViewById(R.id.title);
		link = (TextView) findViewById(R.id.link);
		desc = (WebView) findViewById(R.id.desc);
		// set webview properties
		WebSettings ws = desc.getSettings();
		ws.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
		ws.getPluginState();
		ws.setPluginState(PluginState.ON);
		ws.setJavaScriptEnabled(true);
		ws.setBuiltInZoomControls(true);

		// Set the views
		title.setText(feed.getItem(pos).getTitle());
		link.setText(feed.getItem(pos).getLink());
		//String web = link.toString();
		//System.out.println(feed.getItem(pos).getLink());
		//System.out.println(web);
		startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(feed.getItem(pos).getLink())));
		// desc=new WebView(this);
		//desc.loadDataWithBaseURL("http://www.24h.com.vn/", feed.getItem(pos).getDescription(),
				//"text/html", "UTF-8", "about:blank");

		// setContentView(desc);
	}

}
